package javaJob.exercise.primary.string;

import java.util.ArrayList;
import java.util.HashSet;

public class primary13 {
    public static void main(String[] args) {
        String s = "leetcode";
        String ss = "loveleetcode";
        String sss = "aabb";
        System.out.println(firstUniqChar(s));
    }

    static int firstUniqChar(String s) {
        int answer=-1;
        int[] tag = new int[26];
        for (char a:s.toCharArray()){
            tag[a-'a']++;
        }
        for (int i=0;i<s.length();i++){
            if (tag[s.charAt(i)-'a']==1){
                answer=i;
                break;
            }else {
                answer=-1;
            }
        }
        return answer;
    }
}
